home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / AOCE Sample Code / PowerTalk Access Modules / Sample SMSAM / SampleSMSAM Source / SampleSMSAMServer / 2020toConnectorGateway.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-28  |  4.2 KB  |  145 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        2020toConnectorGateway.h
  3.  
  4.     Copyright:    © 1991-1994 by Apple Computer, Inc.
  5.                 All rights reserved.
  6.  
  7.     Part of the AOCE Sample SMSAM Package.  Consult the license
  8.     which came with this software for your specific legal rights.
  9.  
  10. */
  11.  
  12.  
  13.  
  14. #ifndef __2020TOCONNECTORGATEWAY__
  15. #define __2020TOCONNECTORGATEWAY__
  16.  
  17. #ifndef __BLJSTANDARDINCLUDES__
  18. #include "BLJStandardIncludes.h"
  19. #endif
  20.  
  21. #ifndef __TUPLEDATABASE__
  22. #include "TupleDatabase.h"
  23. #endif
  24.  
  25. #ifndef __MAILGATEWAY__
  26. #include "MailGateway.h"
  27. #endif
  28.  
  29. #ifndef __PASCALSTRING__
  30. #include "PascalString.h"
  31. #endif
  32.  
  33. /***********************************|****************************************/
  34.  
  35. class T2020HalfGateway;
  36. class TConnectorHalfGateway;
  37.  
  38. /***********************************|****************************************/
  39.  
  40. class T2020toConnectorGateway : public TMailGateway 
  41. {    
  42. public:
  43.                                     T2020toConnectorGateway( short vRefNum, long dirID );    
  44.     virtual                         ~T2020toConnectorGateway();
  45.  
  46.     //    This sets the gateway up and gets it ready to start running.
  47.     virtual Boolean    Setup ( short vRefNum, long dirID, const char* gatewayName );    //    this will load the named configuration
  48.  
  49.     //    This 'starts' the gateway off and running.
  50.     virtual Boolean    Run(void);
  51.  
  52.     //    This prepares the gateway to shut down.  The gateway won't be fully shut down until the
  53.     //    ReadyToShutDown() returns true.
  54.     virtual Boolean    PrepareToShutDown(long inHowManySeconds);
  55.     virtual Boolean    ReadyToShutDown(void);
  56.     virtual Boolean    CancelGatewayShutdown (void);
  57.     virtual Boolean    ShutDown(void);
  58.     
  59.     //    These deal with sending a letter from the local system to the remote system.
  60.     virtual Boolean ReceiveLetter (TLetter *letter, THalfGateway *originatorGateway);
  61.     virtual Boolean RereceiveLetter(TLetter* letter, THalfGateway* originatorHalfGateway);
  62.  
  63.     //
  64.     //    CONFIGURATION / SETUP METHODS
  65.     //    =============================
  66.     //
  67.     virtual Boolean                    GetConfigItem(const ATupleKey& key, ADataItem& );
  68.     virtual Boolean                    SetConfigItem(const ATupleKey& key, const ADataItem& );
  69.     virtual Boolean                    DeleteConfigItem(const ATupleKey& key);
  70.     virtual Boolean                    GetNthConfigKey(unsigned long index, ATupleKey& key);
  71.     
  72.     //
  73.     //    STATUS REPORTING / ERROR REPORTING OPTIONS
  74.     //    ==========================================
  75.     //
  76.     virtual Boolean                    GetStatusItem(const ATupleKey& key, ADataItem& );
  77.     virtual Boolean                    SetStatusItem(const ATupleKey& key, const ADataItem& );
  78.     
  79.     virtual Boolean                    GetStatusStr ( CStr255 statusStr ) const;
  80.     virtual Boolean                    SetStatusStr ( CStr255 statusStr );
  81.  
  82.     virtual Boolean                    HandleMonitoringEvent ( const ADataItem& event );
  83.  
  84. protected:
  85.     virtual void                    PeriodicTasks();
  86.     virtual void                    DoShutDownThread ( unsigned long inHowManySeconds );
  87.     
  88.     friend void ShutDownThreadWrapper ( unsigned long g, unsigned long h );
  89.     
  90.             ATupleDatabase            *fConfigurationDB;
  91.             ATupleDatabase            *fStatusDB;
  92.  
  93.             T2020HalfGateway*        f2020HalfGateway;
  94.             TConnectorHalfGateway*    fConnectorHalfGateway;
  95.     
  96.             TThread *                fPeriodicTasks;
  97.             TThread *                fShuttingDownThread;
  98.                             
  99.             unsigned long            fGatewayLetterCount;
  100.             unsigned long            fGatewayStartTime;
  101.             
  102.             Boolean                    fShuttingDown;
  103.             unsigned long            fTimeToShutdownAt;
  104.             CStr255                    fStatusStr;
  105. };
  106.  
  107. /***********************************|****************************************/
  108. /***********************************|****************************************/
  109.  
  110. #pragma segment T2020toConnectorGateway
  111.  
  112. inline Boolean 
  113. T2020toConnectorGateway::GetConfigItem(const ATupleKey& key, ADataItem& data ) 
  114. {
  115.     return fConfigurationDB->GetTupleData ( key, data );
  116. }
  117.  
  118. /***********************************|****************************************/
  119.  
  120. inline Boolean 
  121. T2020toConnectorGateway::SetConfigItem(const ATupleKey& key, const ADataItem& data ) 
  122. {
  123.     return fConfigurationDB->SetTuple ( key, data );
  124. }
  125.  
  126. /***********************************|****************************************/
  127.  
  128. inline Boolean 
  129. T2020toConnectorGateway::DeleteConfigItem(const ATupleKey& key) 
  130. {
  131.     return fConfigurationDB->DeleteTuple( key );
  132. }
  133.  
  134. /***********************************|****************************************/
  135.  
  136. inline Boolean 
  137. T2020toConnectorGateway::GetNthConfigKey(unsigned long index, ATupleKey& key) 
  138. {
  139.     return fConfigurationDB->GetTupleKey ( index, key );
  140. }
  141.         
  142. /***********************************|****************************************/
  143.  
  144. #endif
  145.